package com.bootcamp.s3_1013.database._1018_transaction;

import com.bootcamp.s3_1013.database.utils.JDBCUtils;
import com.bootcamp.s3_1013.database.utils.MyConnectionPool;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @program: myClassCode
 * @description: my own connection pool
 * @author: Keyu Li
 * @create: 2021-10-18 17:15
 **/

public class Demo4_ConnectionPool {
    public static void main(String[] args) throws SQLException {
        //get connection
        Connection connection = MyConnectionPool.getConnection();
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from emp");
        while (resultSet.next()){
            int empno = resultSet.getInt("empno");
            String ename = resultSet.getString("ename");
            String job = resultSet.getString("job");
            System.out.println(empno+", "+ename+", "+job);
        }
        JDBCUtils.closeSources(null,statement,resultSet);
        MyConnectionPool.putConnection(connection);
    }
}


